<?php
/*
	系统首页
*/	
class Index extends Admin_controller{

	public function __construct(){
		parent::__construct();
		parent::logged_check();
		//加载log模型
		$this->load->model('log_model');

	}
	/************
	*	系统首页
	*/
	public function index(){

		// 系统信息
		$this->load->model('site_model');
		$this->data['siteinfo'] = $this->site_model->get_site_info();
		
		// 数据库
		$this->data['dbinfo'] = $this->db->platform() . ' ' . $this->db->version();
		
		
		// 客户端IP
		if ($_SERVER['REMOTE_ADDR']) {
			$cip = $_SERVER['REMOTE_ADDR'];
		} elseif (getenv("REMOTE_ADDR")) {
			$cip = getenv("REMOTE_ADDR");
		} elseif (getenv("HTTP_CLIENT_IP")) {
			$cip = getenv("HTTP_CLIENT_IP");
		} else {
			$cip = "未知";
		}
		$this->data[ 'cip' ] = $cip;
		
		// 浏览器
		$this->load->library( 'user_agent' );
		if( $this->agent->is_browser() )
			$agent = $this->agent->browser() . ' ' . $this->agent->version();
		else if( $this->agent->is_mobile() )
			$agent = $this->agent->mobile();
		else if( $this->agent->is_robot() )
			$agent = $this->agent->robot();
		else
			$agent = '未知浏览器';
		
		$agent .= ' ' . $this->agent->platform();
		$this->data[ 'agent' ] = $agent;
		
		// 用户日志
		$this->load->model( 'log_model' );
		$this->data[ 'log' ] =$this->log_model->get_log( 5 );
		
		$this->view( 'index' );
	}
}
